package com.medical.doctor.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.Query;

import com.medical.doctor.dao.DoctorDepartmentDao;
import com.medical.doctor.entity.DoctorDepartmentEntity;
import com.medical.doctor.service.DoctorDepartmentService;


@Service("doctorDepartmentService")
public class DoctorDepartmentServiceImpl extends ServiceImpl<DoctorDepartmentDao, DoctorDepartmentEntity> implements DoctorDepartmentService {

    @Override
    public PageUtils queryPageById(Map<String, Object> params, Integer hospitalId) {
        QueryWrapper<DoctorDepartmentEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("hospital_id",hospitalId);
        if(params.get("departmentName")!=null&&params.get("departmentName")!=""){
            wrapper.eq("department_name",params.get("departmentName"));
        }
        IPage<DoctorDepartmentEntity> page = this.page(
                new Query<DoctorDepartmentEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DoctorDepartmentEntity> page = this.page(
                new Query<DoctorDepartmentEntity>().getPage(params),
                new QueryWrapper<DoctorDepartmentEntity>()
        );
        return new PageUtils(page);
    }

}